package pkg

import (
	"crypto/hmac"
	"crypto/sha256"
)

type Sign struct {
}

// 签名
func (s *Sign) Sign(key, data []byte) []byte {
	var h = hmac.New(sha256.New, key)
	h.Write(data)
	return h.Sum(nil)
}

// 验签
func (s *Sign) Verify(key, data, sign []byte) bool {
	return hmac.Equal(sign, s.Sign(key, data))
}
